#!/usr/local/bin/lua
--
--	Chapter 22	-	Date and Time
--
--	Michael Ge
--	2014.05.19
--

print("====================")

print(os.time{year = 1970, month = 1, day = 1, hour = 0})
print(os.time{year = 1970, month = 1, day = 1, hour = 0, sec = 1})
print(os.time{year = 1970, month = 1, day = 1})

print("====================")

local date = os.date("*t", 906000490)
print("Year = ", date.year)
print("Month = ", date.month)
print("Day = ", date.day)
print("YDay = ", date.yday)
print("WDay = ", date.wday)
print("Hour = ", date.hour)
print("Min = ", date.min)
print("Sec = ", date.sec)
print("isdst = ", date.isdst)

print("====================")

print(os.date("today is %A, in %B"))
print(os.date("%x", 906000490))

print("====================")

local x = os.clock()
local s = 0
for i = 1, 1000 do
	s = s + i
end
print(string.format("elapsed time: %.2f\n", os.clock() - x))

print("====================")